package odgs;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class SaveUtil
{
	public static Object load(File file)
	{
		FileInputStream fileStream;
		try
		{
			fileStream = new FileInputStream(file);
			ObjectInputStream is = new ObjectInputStream(fileStream);
			Object o = is.readObject();
			is.close();
			fileStream.close();
			return o;
		}
		catch (Exception e)
		{
			e.printStackTrace();
			return null;
		}
	}
	
	public static void save(File file, Object data)
	{
		try
		{
			FileOutputStream fileStream = new FileOutputStream(file);
			ObjectOutputStream os = new ObjectOutputStream(fileStream);
			os.writeObject(data);
			os.close();
			fileStream.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
}
